package demo;


import java.util.*;

public class Test {
    public enum TEST {
        AA, BB
    }

    public static TEST test = TEST.AA;

    public static void main(String[] args) {
        boolean b = isValid("()");
        System.out.println(b);
    }

    public static void getMax() {
        int[] array = new int[10];
        for (int i = 0; i < 10; i++) {
            array[i] = i;
        }
        int max = Arrays.stream(array).max().getAsInt();
        int sum = Arrays.stream(array).sum();

        System.out.println(max);
        System.out.println(sum);
    }

    //检验括号
    public static boolean isValid(String s) {

        if (s == null && s.length() / 2 != 0) {
            return false;
        }

        Map<Character, Character> map = new HashMap<Character, Character>();

        map.put(')', '(');
        map.put(']', '[');
        map.put('}', '{');

        LinkedList<Character> stack = new LinkedList<Character>();

        for (int i = 0; i < s.length(); i++) {
            if (map.containsKey(s.charAt(i)) && !stack.isEmpty() && stack.peek() == map.get(s.charAt(i))) {
                stack.pop();
            } else {
                stack.push(s.charAt(i));
            }
        }

        return stack.isEmpty();
    }
}
